#pragma once

#include "public.h"

class CFileLoader
{
public:
	CFileLoader(void);
	~CFileLoader(void);

	//! Open a file with the specify mode
	bool open(const char* pszFile, const char* mode);

	//! Read data from file
	// return: real read size
	u32	 readData(void* pDst, u32 readsize);

	//! write data to file
	u32  writeData(void* pSrc, u32 size);

	//! close the file
	void close();

	//! Get the file size
	u32 getFileSize() const { return m_uFileSize; }

	//! whether the file is open 
	bool isOpen();

	//! Set file pointer to pos from begin
	void setFilePos(u32 pos);

	//! Forward pos from now position
	void forwardFilePos(u32 pos);

	//! Backward pos from now position
	void backwardFilePos(u32 pos);

	//! Get file name
	std::string getFileName() const { return m_strFileName; }
protected:
	//! File pointer
	FILE*				m_pFile;
	
	//! file name
	std::string			m_strFileName;

	//! file size
	u32					m_uFileSize;

	//! current file pointer
	u32					m_uPos;
};
